const Service = require('egg').Service;

class loginService extends Service {
    async login(request) {
        const { ctx } = this;
        const { username,password } = request;
        var msg,code,id;
        var res = await ctx.model.User.find({userName:username,userPwd:password});
        if(res.length){
            code = 200
            msg = "登录成功"
            id = res[0]._id
        }else{
            code = 400
            msg = "登录失败，用户名或者密码错误"
        }
        return {code,msg,id}
    };
    async logout() {
        // 无需操作数据库
    }
}
module.exports = loginService